﻿package com.sh.game.util
{
    import flash.events.*;
    import flash.net.*;
    import flash.utils.*;

    public class NbLog extends Object
    {
        private var _errorInterval:int = 300000;
        private var _lastTime:int = -300000;
        private var _url:String;
        private static var _instance:NbLog;

        public function NbLog()
        {
            return;
        }// end function

        public function init(param1:String) : void
        {
            this._url = param1;
            return;
        }// end function

        public function checkError(param1:Error, param2:int, param3:String) : void
        {
            var _loc_6:Object = null;
            var _loc_7:URLVariables = null;
            var _loc_4:* = getTimer();
            var _loc_5:* = getTimer() - this._lastTime;
            if (getTimer() - this._lastTime > this._errorInterval)
            {
                _loc_6 = UserData.getUserData();
                _loc_7 = new URLVariables();
                _loc_7.user = _loc_6 != null ? (encodeURI(_loc_6.name)) : ("unknow");
                _loc_7.error = encodeURI(param1.message);
                _loc_7.type = param2;
                _loc_7.plus = param3;
                this.log(this._url, _loc_7);
                this._lastTime = _loc_4;
            }
            return;
        }// end function

        private function log(param1:String, param2:Object) : void
        {
            var _loc_3:* = new URLRequest(param1);
            _loc_3.method = URLRequestMethod.POST;
            _loc_3.data = param2;
            var _loc_4:* = new URLLoader();
            new URLLoader().addEventListener(IOErrorEvent.IO_ERROR, this.ioError, false, 0, true);
            _loc_4.load(_loc_3);
            return;
        }// end function

        private function ioError(event:IOErrorEvent) : void
        {
            return;
        }// end function

        public static function getInstance() : NbLog
        {
            if (_instance == null)
            {
                _instance = new NbLog;
            }
            return _instance;
        }// end function

    }
}
